<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>转账汇款</title>
    <style>
        body {
            background-color: lightseagreen;
        }
        .container{
            text-align: center;
            background-color: white;
            width: 400px;
            position: absolute;
            left:50%;
            top:50%;
            margin-left:-200px;
            margin-top:-100px;
            padding: 20px;
        }
        .item {
            margin-top: 15px;
            line-height: 40px;
        }
        .item input {
            line-height: 25px;
            width: 200px;
        }
        #btn {
            line-height: 35px;
            background-color: lightseagreen;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="item">
        收款账户：<input type="text" name="toAccount" id="toAccount" value="韩梅梅 6028123122123"/>
    </div>
    <div class="item">
        付款账户：<input type="text" name="fromAccount" id="fromAccount" value="李大雷 6028123122124"/>
    </div>
    <div class="item">
        转账金额：<input type="text" name="money" id="money"/>
    </div>
    <div class="item">
        <input type="button" value="提交" id="btn"/>
    </div>
</div>
<script type="application/javascript" src="js/jquery.min.js"></script>
<script type="application/javascript">
    $(function () {
        $("#btn").bind("click", () => {
            let fromAccount = $("#fromAccount").val();
            let toAccount = $("#toAccount").val();
            let money = $("#money").val();
            if (money == null || $.trim(money).length == 0) {
                alert("sorry，必须输入转账金额~");
                return;
            }
            $.ajax({
                url: '/transferServlet',
                type: 'POST',
                async: false,
                data: {
                    fromCardNo: fromAccount.split(" ")[1],
                    toCardNo: toAccount.split(" ")[1],
                    money: money
                },
                timeout: 5000,
                dataType: 'json',
                success: function (data) {
                    if ("200" == data.status) {
                        alert("转账成功~~")
                    } else {
                        alert("转账失败~~,message:" + data.message);
                    }
                }
            })
        })
    })
</script>
</body>
</html>